package com.example.administrator.printoutindemo;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Mothsked implements Serializable{

	private String material;
	private String plandate;
	private int mstatus;
	private int mid;
	private String msBH;
	private String JSdate;
	private byte[] cyimg;
	private byte[] fqimg;

	public String ConvertToJson(Mothsked model) {
		String jsonStr = "";
		JSONObject modelJsonObject = new JSONObject();
		try {
			modelJsonObject.put("material", model.getMaterial());
			modelJsonObject.put("JSdate", model.getJSdate());
			modelJsonObject.put("mid", model.getMid());
			modelJsonObject.put("mstatus", model.getMstatus());
			modelJsonObject.put("cyimg", "");
			modelJsonObject.put("fqimg", "");

			jsonStr = modelJsonObject.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jsonStr;
	}

	// 将JSON对象转化为list
	public List<Mothsked> getListFromJSON(String JsonStr) {
		List<Mothsked> clist = new ArrayList<Mothsked>();
		try {

			JSONArray jay = new JSONArray(JsonStr);// 将字符串转化为JSON数组

			for (int i = 0; i < jay.length(); i++) {
				JSONObject temp = (JSONObject) jay.get(i);

				Mothsked n = new Mothsked();

				n.setMaterial(temp.getString("material"));
				n.setMstatus(Integer.parseInt(temp.getString("mstatus")));
				n.setPlandate(temp.getString("plandate"));
				n.setMid(Integer.parseInt(temp.getString("mid")));
				n.setMsBH(temp.getString("msBH"));

				clist.add(n);

			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return clist;

	}


	public String getMaterial() {
		return material;
	}



	public void setMaterial(String material) {
		this.material = material;
	}



	public String getPlandate() {
		return plandate;
	}



	public void setPlandate(String plandate) {
		this.plandate = plandate;
	}



	public int getMstatus() {
		return mstatus;
	}



	public void setMstatus(int mstatus) {
		this.mstatus = mstatus;
	}



	public int getMid() {
		return mid;
	}



	public void setMid(int mid) {
		this.mid = mid;
	}



	public String getMsBH() {
		return msBH;
	}



	public void setMsBH(String msBH) {
		this.msBH = msBH;
	}



	public String getJSdate() {
		return JSdate;
	}



	public void setJSdate(String jSdate) {
		JSdate = jSdate;
	}



	public byte[] getCyimg() {
		return cyimg;
	}



	public void setCyimg(byte[] cyimg) {
		this.cyimg = cyimg;
	}



	public byte[] getFqimg() {
		return fqimg;
	}



	public void setFqimg(byte[] fqimg) {
		this.fqimg = fqimg;
	}



	public Mothsked(){}
}